package com.aocuploader;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

import com.aocuploader.LoginPage.LoginPageTask;

import android.os.Bundle;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class MainMenu extends Activity {
	private TextView welco;
	private Button gallery;
	private Button chatbox;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.mainmenu);
        
        TextView welco = (TextView) findViewById(R.id.welco);
        ImageView fotofoto = (ImageView) findViewById(R.id.fotoku);
        welco.setText("Hello, " + LoginPage.nama);
        
        gallery = (Button) findViewById(R.id.gallery);
        gallery.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {
				Intent uploadimage = new Intent(getApplicationContext(),ImageUpload.class);
				startActivity(uploadimage);
			}
		});
        
        try {
			URL url = new URL("http://aocunited.com/images/avatar/"+ LoginPage.muka);
			URLConnection conn;
			conn = url.openConnection();
			conn.connect();
			InputStream is = conn.getInputStream();
			BufferedInputStream bis = new BufferedInputStream(is);

			Bitmap bm = BitmapFactory.decodeStream(bis);
			fotofoto.setImageBitmap(bm);

			bis.close();
			is.close();
			
			
			
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        
        
        
        chatbox = (Button) findViewById(R.id.chatbox);
        chatbox.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {
				Intent chatbox = new Intent(getApplicationContext(),ChatBox.class);
				startActivity(chatbox);
			}
		});
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.mainmenu, menu);
        return true;
    }
}
